/**
 * Author: w景洋.
 * Time: 2016/4/19 0019
 */
angular.module('expert.service.auth', [
        "ngResource",
        "ngStorage"
    ])
    //认证服务
    .service('ExpAuthService', ['$resource', '$localStorage', function ($resource, $localStorage) {
        var $storage = $localStorage.$default({
            name: '',
            userId: '',
            wxpay_openid: '',
        });
        // 已登录则返回userid，否则跳转指定地址
        this.ensure_login = function () {
            if ($storage.userId) {
                return $storage.userId;
            }
            alert("您还未登录,请先登录")
            window.location.href = projectBaseUrl + "login";
        }

        this.getUserid = function () {
            return $storage.userId;
        }
    }])